/*
 * Author: nicolas.bredeche(@)lri.fr
 * Created on 11 d�c. 2006
 * 
 */

package picoevo.tutorials.es.cmaesdemo;

import picoevo.core.evolution.ParameterSet;
import picoevo.es.cmaes.EvaluationOperatorForCMAES;

/**
 * a very classic sphere function for demo purpose (adapted from CMA-ES original
 * examples)
 */

public class SphereFunctionEvaluationOperator extends EvaluationOperatorForCMAES {

	public SphereFunctionEvaluationOperator(ParameterSet __params) {
		super(__params);
	}

	public SphereFunctionEvaluationOperator() {
		super(null);
	}

	@Override
	public double valueOf(double[] x) {
		double res = 0;
		for (int i = 0; i < x.length; ++i)
			res += x[i] * x[i];
		// return res;
		return 1 / (1 + res); // [!n] max!
	}
}
